package stage1.module3.Q2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Worker> workers = new ArrayList<>();

        Worker fengjie = new Worker("凤姐", 18, 20000);
        Worker ouyangfeng = new Worker("欧阳锋", 60, 800);
        Worker liudehua = new Worker("刘德华", 40, 30000);

        workers.add(fengjie);
        workers.add(ouyangfeng);
        workers.add(liudehua);

        System.out.println(Arrays.toString(workers.toArray()));

        Worker zhangbozhi = new Worker("张柏芝", 35, 3300);
        workers.add(workers.indexOf(ouyangfeng), zhangbozhi);

        System.out.println(Arrays.toString(workers.toArray()));

        workers.remove(liudehua);

        System.out.println(Arrays.toString(workers.toArray()));

        for (Worker w : workers) {
            System.out.println(w);
        }

        Iterator<Worker> i = workers.iterator();
        while (i.hasNext()) {
            Worker w = i.next();
            w.work();
        }
    }
}
